package com.wxtt.android.animation;

import android.view.View;

import com.nineoldandroids.animation.AnimatorSet;
import com.nineoldandroids.view.ViewHelper;

/**
 * 说明：BaseEffects
 * <p/>
 * 作者：fanly
 * <p/>
 * 时间：2016/1/1 23:09
 * <p/>
 * 版本：verson 1.0
 */
public abstract class BaseEffects {

    private static final int DURATION = 400;
    protected long mDuration =DURATION ;
    private AnimatorSet mAnimatorSet;
    {
        mAnimatorSet = new AnimatorSet();
    }
    protected abstract void setupAnimation(View view);

    public void start(View view) {
        reset(view);
        setupAnimation(view);
        mAnimatorSet.start();
    }
    public void reset(View view) {
        ViewHelper.setPivotX(view, view.getMeasuredWidth() / 2.0f);
        ViewHelper.setPivotY(view, view.getMeasuredHeight() / 2.0f);
    }


    public AnimatorSet getAnimatorSet() {
        return mAnimatorSet;
    }

    public void setDuration(long duration) {
        this.mDuration = duration;
    }
}
